<template>
  <div style="background-color: #FFFFFF; width: 100%; height: 1000px; padding: 15px;">
    <div style="margin-left: 26px; font-size: 13px; font-weight: bold;">
      <span>用工历史记录</span>
    </div>
    <div style="margin-left: 20px;margin-top: 20px; padding:5px">
      <a-row :gutter="16">
       <a-col :span="3">
       	<j-dict-select-tag style="width: 100%" placeholder="请选择公司" v-model="queryParam.company"
       		dictCode="crm_company,name,id" disabled />
       </a-col>
       <a-col :span="3">
       	<j-dict-select-tag style="width: 100%" placeholder="请选择车间" v-model="queryParam.workshop"
       		dictCode="workshop" />
       </a-col>
       <a-col :span="3">
       	<j-dict-select-tag style="width: 100%" placeholder="请选择工序" v-model="queryParam.productCategory"
       		dictCode="product_category" />
       </a-col>
       
       <a-col :span="5">
	   <j-dict-select-tag style="width: 100%" placeholder="请选择班次" v-model="queryParam.shift"
	   	dictCode="shift" />
       </a-col>
       <a-col :span="14">
       	<div>
       		<RangePicker v-model="queryTime" @change="onChange"></RangePicker>
       	</div>
       </a-col>
       
       <a-col :span="2">
       	<div>
       		<a-button @click="searchQuery()" type="primary" style="margin-top: 10px;">
       			查询
       		</a-button>
       	</div>
       </a-col>
      </a-row>

      <div style="margin-top: 30px;">
        <a-table :columns="columns"  :data-source="dataSource"  rowKey="id" :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" :pagination="ipagination"
               :loading="loading" @change="handleTableChange">
          <a slot="name" slot-scope="text">{{ text }}</a>
        </a-table>
      </div>


    </div>
  </div>

</template>
<script>

const columns = [

  {
    title: '组织',
    dataIndex: 'company_dictText',
    key: 'company_dictText',
    width: 200,
  },
  {
    title: '车间',
    dataIndex: 'workshopText',
    key: 'workshopText',
    ellipsis: true,
  },
  {
    title: '工序',
    dataIndex: 'productCategoryText',
    key: 'productCategoryText',
    ellipsis: true,
  },
  
  {
    title: '班次',
    dataIndex: 'shiftText',
    key: 'shiftText',
    ellipsis: true,
  },
  {
    title: '实际用工（时）',
    dataIndex: 'actualWorkers',
    key: 'actualWorkers',
    ellipsis: true,
  },
  {
    title: '万锭用工（时）',
    dataIndex: 'tenThousandIngotsWorkers',
    key: 'tenThousandIngotsWorkers',
    ellipsis: true,
  },
  {
    title: '日期',
    dataIndex: 'createTime',
    key: 'createTime',
    ellipsis: true,
  },

];

const data = [];
import RangePicker from '@comp/RangePicker/RangePicker.vue'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import moment from 'moment/moment'
import {
		getAction
	} from '@/api/manage'
	import {
		getCrmDeviceParamList
	} from '@api/api'
export default {
	components: {
		RangePicker
	},
	mixins: [JeecgListMixin],
  data() {
    return {
      queryTime: null,
      data,
      columns,
      // 查询条件
      queryParam: {
			   company: '1771136798305476610',
			   productCategory: undefined,
			   workshop: undefined,
				// 机台号
				deviceNo: undefined,
				// 开始时间
				startTime: moment().format('YYYY-MM-DD 00:00:00'),
				// 结束时间
				endTime: moment().format('YYYY-MM-DD 23:59:59'),
				// 参数id
				paramId: undefined,
				shift:undefined
      },
      options: [],
      deviceList: [],
			url:{
				list:'crm_worker_record/crmWorkerRecord/selectWorkerRecord'
			}
    }
  },
  methods: {
    getDeviceList() {
    	this.deviceList = []
    	// 车间和工序都选才去查询
    	if (!this.queryParam.workshop || !this.queryParam.productCategory) {
    		return
    	}
    	const params = {
    		workshop: this.queryParam.workshop,
    		workingProcedure: this.workingProcedure[this.queryParam.productCategory],
    		pageSize: -1
    	}
    	getAction('/crm_device/crmDevice/list', params).then(res => {
    		this.deviceList = res.result.records.map(item => {
    			return {
    				label: item.workingProcedure_dictText + item.deviceNo,
    				value: item.deviceNo
    			}
    		});
    	})
    },
    onChange(date, dateString) {
    	this.queryParam.startTime = this.queryTime[0]
    	this.queryParam.endTime = this.queryTime[1]
    }

  },

};
</script>
